#ifndef __PROCESSOR_HPP__
#define __PROCESSOR_HPP__

#include "core.hpp"
#include "io.hpp"

class Processor
{
private:
	std::map<int, CalcCore *> cores;
	std::map<int, MMU *> MMUs;
	std::map<int, Cache *> CACHEs;
	std::map<uint16_t, ProgramIO *> io;
	Atomic<IOBus *> bus;
	Atomic<CacheMessage> cache_msg;

	void newCore(int);
	void operator()(uint64_t, uint16_t, uint8_t);

public:
	Processor() = default;
	~Processor() = default;
	void init(Atomic<IOBus *> &);
	void run();
	void mountIO(uint16_t, const IOTYPE, const char *);
	void detachIO(uint16_t id)
	{
		delete io[id];
		io.erase(id);
	}
};

#endif